package com.ruicar.afs.cloud.common.vo;

import com.ruicar.afs.cloud.common.modules.contract.enums.LendingDirection;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * @author infinity
 * @version 1.0
 * @date 2020/8/21 22:39
 */
@Data
public class AccountVoucherEntryVo {
    private Long id;
    @ApiModelProperty("凭证号")
    @NotBlank(message = "凭证号不能为空")
    private String voucherNo ;

    @ApiModelProperty("分录序号")
    @NotBlank(message = "分录序号不能为空")
    private Integer entryNo ;

    @ApiModelProperty("科目代码")
    @NotBlank(message = "科目代码不能为空")
    private String subjectCode ;

    @ApiModelProperty("科目名称")
    @NotBlank(message = "科目名称不能为空")
    private String subjectName ;

    @ApiModelProperty("借贷方向")
    @NotNull(message = "借贷方向不能为空")
    private LendingDirection lendingDirection ;

    @ApiModelProperty("借方金额")
    @NotBlank(message = "借方金额不能为空")
    private BigDecimal debitAmt ;

    @ApiModelProperty("贷方金额")
    @NotBlank(message = "贷方金额不能为空")
    private BigDecimal creditAmt ;

    @ApiModelProperty("摘要")
    @NotBlank(message = "摘要不能为空")
    private String explanation ;
    public static AccountVoucherEntryVo convertFrom(VoucherEntryVo voucherEntry){
        AccountVoucherEntryVo entry = new AccountVoucherEntryVo();
        entry.setLendingDirection(voucherEntry.getLendingDirection());
        entry.setEntryNo(voucherEntry.getOrderNum());
        entry.setSubjectCode(voucherEntry.getSubjectCode());
        entry.setSubjectName(voucherEntry.getSubjectName());
        entry.setExplanation(voucherEntry.getExplanation());
        return entry;
    }
}
